//
//  ViewController.m
//  XMLhomeWork
//
//  Created by 苗钧豪 on 16/8/10.
//  Copyright © 2016年 苗钧豪. All rights reserved.
//

#import "ViewController.h"
#import "GDataXMLNode.h"
#import "Movie.h"
@interface ViewController ()
@property (nonatomic , strong) NSMutableArray *stuArr;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)ReadXMLForDOM:(id)sender {
    self.stuArr = [NSMutableArray array];
    NSString *XMLPath = [[NSBundle mainBundle] pathForResource:@"homeWork" ofType:@"xml"];
    NSData *data = [NSData dataWithContentsOfFile:XMLPath];
    NSError *error = nil;
    GDataXMLDocument *document = [[GDataXMLDocument alloc]initWithData:data options:0 error:&error];
    GDataXMLElement *rootElement = [document rootElement];
    NSLog(@"0000000000000000000000~%@",rootElement.name);
    NSArray *rootElement1 = rootElement.children;
    for (GDataXMLElement *Element1 in rootElement1) {
        NSLog(@"11111111111111111111~%@",Element1.name);
        for (GDataXMLElement *Element2 in Element1.children) {
            NSLog(@"2222222222222222222222~%@",Element2.name);
            if ([Element2.name isEqualToString:@"AlbumInfo"]) {
                NSLog(@"33333333333333333~%@",Element2.stringValue);
                NSArray *rootElement2 = Element2.children;
                for (GDataXMLElement *Element3 in rootElement2) {
                    NSLog(@"4444444444444444~%@",Element3.name);
                        for (GDataXMLElement *Element4 in Element3.children) {
                            NSLog(@"555555555555555555555~%@",Element4.stringValue);
//                            Movie *movie = [Movie new];
//                            [movie setValue:Element3 forKey:Element3.stringValue];
//                            [_stuArr addObject:movie];
                            NSString *str = Element4.stringValue;
                            [_stuArr addObject:str];
                    }
                }
            }
        }
    }
    NSLog(@"%@",_stuArr);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
